<?php
require_once('../../djavupixel/wordpress/wp-blog-header.php');
header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
$more = 1;

$items = array();
query_posts("");
while (have_posts()) :
the_post();
$item = array(
	"title" => get_the_title_rss(),
	"link" => apply_filters('the_permalink_rss', get_permalink()),
	"description" => apply_filters('the_excerpt_rss', get_the_excerpt()));
$items[] = $item;
endwhile;

$arr = array(
'title' => get_bloginfo_rss('name'),
'link' => get_bloginfo_rss('url'),
'description' => get_bloginfo_rss('description'),
'language' => get_option('rss_language'),
'item' => $items);

echo "".$HTTP_GET_VARS["callback"]."(".json_encode(array('posts' => $arr)).");";


//define('WP_USE_THEMES', false);
//require_once('../../djavupixel/wordpress/wp-blog-header.php');
//
//// set header for json mime type
//header('Content-type: application/json;');
//
//$posts = array();
//
//$numberposts = 5;
//$offset = (intval($_GET['page']) - 1) * $numberposts;
//
//$num_posts = wp_count_posts('post');
//
////print_r($num_posts);
//
//$num_pages = intval($num_posts->publish / $numberposts);
//if ($num_posts->publish % $numberposts != 0) {
//    $num_pages++;
//}
//
//if ($page <= $num_pages) {
//
//    $args = array( 'numberposts' => $numberposts, 'offset'=> $offset );
//    $myposts = get_posts( $args );
//
//    foreach( $myposts as $post ) : setup_postdata($post);
//        $posts[] = array(
//            'id' => $post->ID,
//            'title' => $post->post_title,
//            'permalink' => $post->guid,
//            'date' => str_replace("-", "/", substr($post->post_date, 0, 11)),
//            'author_id' => $post->post_author,
//            'author' => get_userdata($post->post_author)->display_name,
//            //'content' => wpautop(strstr($post->post_content, '<!--more-->', true))
//            'content' => $post->post_content
//            //'content' => wpautop( str_replace(']]>', ']]&gt;', apply_filters('the_content', $post->post_content) ) )
//        );
//    endforeach;
//
//    echo (json_encode(array('posts' => $posts)));
//    
//    //print_r($myposts);
//}

?>
